define(function () {
    var StaffSearch = {
        template:
        '<div class="concluded-top-two">' +
        '        <div class="one-input">' +
        '            <strong>部门：</strong>' +
        '            <strong class="state-input">' +
        '                <cascader v-model="secModel" :data="secList"></cascader>' +
        '            </strong>' +
        '        </div>' +
        '        <div class="one-input">' +
        '            <strong>职位：</strong>' +
        '            <strong class="state-input">' +
        '                <i-select v-model="postModel" placeholder="">' +
        '                    <i-option v-for="item in postList " :value="item.PositionId" :key="item">{{ item.PositionName }}</i-option>' +
        '                </i-select>' +
        '            </strong>' +
        '        </div>' +
        '        <div class="one-input">' +
        '            <strong>权限：</strong>' +
        '            <strong class="state-input">' +
        '                <cascader v-model="limitModel" :data="_limitList"></cascader>' +
        '            </strong>' +
        '        </div>' +
        '        <div class="c-search-box"><span>关键字：</span><input v-model="searchModel" type="text" class="c-input"' +
        '                                                          placeholder="输入手机、姓名、客户来源">' +
        '            <input type="button" class="c-search" value="搜索" @click="getSearchData">' +
        '        </div>' +
        '    </div>',
        props: {
            secList: {
                type: Array,
                default: function () {
                    return [];
                }
            },
            postList: {
                type: Array,
                default: function () {
                    return [];
                }
            },
            limitList: {
                type: Array,
                default: function () {
                    return [];
                }
            }
        },
        data: function () {
            return {
                secModel: '',
                postModel: '',
                limitModel: '',
                searchModel: ''
            }
        },
        watch: {
            secModel: function (val) {
                this.$emit('update:secModel', val);
            },
            postModel: function (val) {
                this.$emit('update:postModel', val);
            },
            limitModel: function (val) {
                this.$emit('update:limitModel', val);
            }
        },
        computed: {
            _limitList: function () {
                var dataList = JSON.parse(JSON.stringify(this.limitList));
                var recursively = function (data) {
                    for (var i = 0; i < data.length; i++) {
                        data[i].value = data[i].num;
                        data[i].label = data[i].content;
                        if (data[i].hasOwnProperty('children')) {
                            recursively(data[i].children);
                        }
                    }
                };
                recursively(dataList);
                return dataList;
            }
        },
        created: function () {
        },
        methods: {
            getSearchData: function () {
                this.$emit('update:searchModel', this.searchModel);
            }
        }
    };
    return StaffSearch
})
